<%@ page import="sematproject.Task" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="barraUsuario">
	</head>
	<body>
		
		<g:render template="/common/barraLateralBacklog" />
		<g:render template="/common/barraBacklogToDo" />

	<div id="pagBacklog">
		<g:form action="toDoing" method="post">
			
			<div id="pagToDoDoingDone">
				<table>
					<thead>
						<tr>
							<td></td>
							<g:sortableColumn property="name" title="Name" />
							<g:sortableColumn property="category" title="Category" />
							<g:sortableColumn property="description" title="Description" />
							<g:sortableColumn property="finishDate" title="Finish Date" />
							<g:sortableColumn property="startedDate" title="Started Date" />
						</tr>
					</thead>
					<tbody>
						<g:each in="${taskInstanceList}" status="i" var="taskInstance">
							<g:each in="${backlogInstance.tasks}"  var="t">
							<g:if test="${taskInstance.state == 0 && t == taskInstance}">
							<tr class="${(i % 2) == 0 ? 'even' : 'od'}">
								<td><g:checkBox name="${taskInstance.name}" value="${false}"/></td>
								<td id="tamNombre"><g:link controller="task" action="show" id="${taskInstance.id}" title="Ver detalles">${fieldValue(bean: taskInstance, field: "name")}</g:link></td>
							 	<td>${fieldValue(bean: taskInstance, field: "category")}</td>
								<td id="tamDescripcion">${fieldValue(bean: taskInstance, field: "description")}</td>
								<td><g:formatDate date="${taskInstance.finishDate}" /></td>
								<td><g:formatDate date="${taskInstance.startedDate}" /></td>
							</tr>
							</g:if>
							</g:each>
						</g:each>
					</tbody>
				</table>
			</div>			
			<g:submitButton id="botonRealizando" name="toDoing" value="Realizando" />
			<g:link controller="task" action="create" id="${backlogInstance.id}"><img id="agregarTareaIcono" title="Agregar una nueva tarea" /></g:link>
		</g:form>	
	</div>
		
	<%--------------------------- Carga el fondo trasparente ---------------------------%>
	<g:link class='fondoTransparente' controller="backlog" action="toDo" id="${backlogInstance.id}"></g:link>
	<%-----------------------------------------------------------------------------------%>
		
		<g:form action="save">
			<ul id="agregarTareaPanel">
				<li><p id="letraGrandeTareaCrear">Nueva tarea</p></li>
				<li><g:field id="campoTextoT" name="name" type="text" value="${taskInstance.name}" required="" placeholder="Nombre"/></li>
				<li><g:select id="selectCategoria" noSelection="${['O1':'Selecciones la categoría...']}" name="category" from="${['O1','O2','O3','O4','O5','O6','I1','I2','I3','I4','I5','I6','R1','R2','R3','R4','R5','R6','S1','S2','S3','S4','S5','S6','T1','T2','T3','T4','T5','T6','E1','E2','E3','E4','E5','F1','F2','F3','F4','F5','F6']}" value="${taskInstance.category}"  /></li>
				<li><g:textArea id="campoAreaT" name="description" type="text" value="${taskInstance?.description}" placeholder="Descripción"/></li>
				<li>Fecha finalización: <g:datePicker name="finishDate" precision="day"  value="${taskInstance?.finishDate}"/><li>
				<li><g:if test="${flash.message}"><p id="errorIngreso">Has introducido un nombre<br>de usuario o una contraseña<br>incorrecta.</p></g:if></li>
				<li><g:submitButton id="botonCrearTarea" name="create" class="save" value="Crear" /></li>
			</ul>
		</g:form>
	</body>
</html>